<template>
	<view class="content">
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
			<swiper-item v-for="(item,index) in lunboList">
				<view class="swiper-item">
					<image :src="item.url" mode="" style="width: 100%;"></image>
				</view>
			</swiper-item>
		 
		</swiper>
		<uni-section title="公交地铁线路查询" sub-title="" type="line">
			 
		</uni-section>
       <uni-search-bar @confirm="searchCityBus" v-model="searchKey"  /> 
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import {
		CONFIG
	} from '../../utils/config';

	onLoad(() => {
		getLunbo()
	})
    let lunboList=ref([])
	async function getLunbo() {
		let res = await uni.$get(CONFIG.leancloud_url + "/1.1/classes/lunbo")
		console.log(res)
		lunboList.value=res.results
	}
	
	let searchKey=ref("")
	function searchCityBus(){
		if(searchKey.value=="")
		{
			uni.showToast({
				title:"请输入搜索线路名称",
				icon:"none"
			})
		}else{
			let url=`https://uri.amap.com/line?name=${searchKey.value}&city=029&callnative=0`
			window.location.href=url
		}
	}
</script>

<style>

</style>